package part16;

import java.util.Arrays;

/**
 * @author wcj
 * @Date 2021/5/31 16:33
 * @Version 1.0
 */
public class Part162 {

    /**
     * 基本类型的数组和对象类型的数组操作上没有差别
     * 唯一的差别在于：基本数据类型数组直接存放的是基本类型的值，而对象数组中元素存放的是对象的引用
     *
     * @param args
     */
    public static void main(String[] args) {
        Bery[] a;
        Bery[] b = new Bery[5];
        System.out.println(Arrays.toString(b));
        Bery[] c = new Bery[4];
        for (int i = 0; i < c.length; i++) {
            if (c[i] == null) {
                c[i] = new Bery();
            }
        }
        Bery[] d = {new Bery(), new Bery(), new Bery()};
        a = new Bery[]{new Bery(), new Bery()};
        System.out.println("a:" + a.length);
        System.out.println("b:" + b.length);
        System.out.println("c:" + c.length);
        System.out.println("d:" + d.length);
        a = d;
        System.out.println("a:" + a.length);

        int[] e;
        int[] f = new int[5];
        System.out.println(Arrays.toString(f));
        int[] g = new int[4];
        for (int i = 0; i < g.length; i++) {
            g[i] = i * i;
        }
        int[] h = {11, 47, 98};
        System.out.println("f:" + f.length);
        System.out.println("g:" + g.length);
        System.out.println("h:" + h.length);
        e = h;
        System.out.println("e:" + e.length);
        e = new int[]{5, 4};
        System.out.println("e:" + e.length);
    }
}

class Bery {
}
